package pkg1;

import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
 
public class JsDemo {
   public static void main(String args[]) throws ScriptException{
   
      ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
      ScriptEngine nashorn = scriptEngineManager.getEngineByName("nashorn");
        
      String name = "Runoob";
    
      
 
         nashorn.eval("print('" + name + "')");
         String jsStr = "10 + 2";
		Object evalRzt = nashorn.eval(jsStr);
		   System.out.println(evalRzt.toString());
         
    
      
   
   }
}